<!DOCTYPE HTML>
<html>
<head>
    <title>Error</title>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/stylesheets/formdata.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">

    <script src="/scripts/miniui/miniui.js"></script>
    <!--<script src="/qiniuJs/liveFormdata.js"></script>-->
    <!--<script src="/qiniuJs/livePicFormdata.js"></script>-->
    <script src="/qiniuJs/audioVedioFormdata.js"></script>

</head>
<body>
<div class="container" style="display: inline-block;width: 100%; margin: 10px">
    <form id="testform" method="post" enctype="multipart/form-data">
        <input name="key" id="key" type="hidden" value="">
        <input name="token" type="hidden" value="<%= uptoken %>">
        <input id="userfile" name="file" accept="audio/mp4,video/mp4" type="file"/>
        <input name="accept" type="hidden"/>
    </form>
    <!-- add file -->
    <label for="userfile">
        <span></span>
        <em>添加视频</em>
    </label>

    <!-- upload info -->
    <div class="selected-file"></div>
    <div class="progress"></div>
    <div class="uploaded-result"></div>
</div>
<div style="margin: 20px  auto;text-align: center">
    <input id="streambackup" required class="mini-textbox" style="display: none"/>
    <input type="text" name="duration" placeholder="请输入时长" id="duration" required="required"
           onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();">秒
</div>
<div style="margin: 0 auto;text-align: center">

    <a class="mini-button " iconCls="icon-ok" onclick="updateMedia()">确定</a>
    <a class="mini-button" iconCls="icon-cancel" onclick="onCancel">取消</a>
</div>
</body>
<script>
    let domain = "<%- domain %>";
    let objectId = "<%- objectId %>"
    let qiniuUpUrl = 'http://up-z0.qiniup.com/'

    function updateMedia() {
        if(!$('#duration').val()){
            alert("请输入时长的值")
            return
        }
        let duration = $('#duration').val();
        let name = $('#key').val();
        let type = 3
        $.ajax({
            type: "POST",
            url: "/tribeRoute/updateMedia",
            data: {
                objectId,
                name,
                type,
                duration
            },
            success: function (result) {
                if (result == 10000) {
                    uploadFile();
//                    CloseWindow("save");
                } else {
                    alert("更改失败");
//                    CloseWindow("save");
                }

            }
        })
    }
    //    关闭窗口
    function CloseWindow(action) {
        if (action == "close" && form.isChanged()) {
            if (confirm("数据被修改了，是否先保存？")) {
                return false;
            }
        }
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }

    function onCancel(e) {
        CloseWindow("cancel");
    }
</script>
</html>